package com.itmayiedu.dao;

import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.itmayiedu.entity.UserEntity;

import feign.Param;

@Mapper
public interface MemberDao {
	@Select("select id,username,password,phone,email,created,updated,token,openid from mb_user where id=#{userId}")
	UserEntity findById(@Param("userId") Long userid);
	@Insert("insert into `mb_user` (username,password,phone,email,created,updated,token,openid) values (#{username}, #{password},#{phone},#{email},#{created},#{updated},#{token},#{openid});")
	Integer insertUser(UserEntity userEntity);
	
	@Select("select  id,username,password,phone,email,created,updated,token,openid from mb_user where username= #{username} and password= #{password}")
	UserEntity login(Map<String,Object> map);
	@Update("update `mb_user` set token=#{token} where id =#{id}")
	Integer addToken(Map<String ,Object> map);
	@Select("select id,username,password,phone,email,created,updated,token,openid from mb_user where openid=#{openid}")
	UserEntity findByOpenIdUser(@Param("openid") String openid);
	@Update("update `mb_user` set openid=#{openid} where id =#{id}")
	Integer updateByOpenIdUser(Map<String,Object> map);
}
